<template>
  <!-- 登陆后，每日推荐 -->
  <div class="daydetail">
    <scroll class="dat-scroll">
      <day-base-info @allPlay="PlayMusic()" />
      <music-item :musiclist="musiclist"
                  @musicItemClick="PlayMusic" />
    </scroll>
  </div>
</template>

<script>
import Scroll from 'components/common/scroll/Scroll.vue'
import MusicItem from '../musicListDetail/childComps/MusicItem.vue'
import { indexMixin } from 'mixin/indexMixin'
import DayBaseInfo from "./childComps/DayBaseInfo";
import {
  _getSongsDetail,
  SongDetail,
} from "network/detail"
import { _getRecommendResource } from "network/discover"
export default {
  name: 'DayMusicListDetail',
  components: { Scroll, MusicItem, DayBaseInfo },
  data () {
    return {
      musiclist: []
    }
  },
  mixins: [indexMixin],
  created () {
    const cookie = this.$store.getters.getCookie;
    if (cookie != '' && cookie != null) {
      // 获取每日推荐的歌曲
      _getRecommendResource(cookie, this.$store.state.uid).then(res => {
        for (const i of res.data.data.dailySongs) {
          _getSongsDetail(i.id).then(res => {
            const song = new SongDetail(res.data.songs);
            this.musiclist.push(song);
          })
        }
      })
    }
  }

}
</script>

<style scoped>
.daydetail {
  width: 100%;
  height: 100%;
  padding: 35px 35px 0 35px;
  color: #000;
  /* background: rgb(247, 247, 239); */
  overflow: hidden;
}
.dat-scroll {
  height: 100%;
}
</style>
